package hot100;


/*
 * Author：江松
 * Date：2023/4/6 15:19
 *
 *
 翻转二叉树：
 后序
 */

public class Main226 {
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode() {}
        TreeNode(int val) { this.val = val; }
        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }


    public TreeNode invertTree(TreeNode root) {
        if(root==null)return null;
        invertTree(root.left);
        invertTree(root.right);
        TreeNode t=root.left;
        root.left=root.right;
        root.right=t;
        return root;
    }
}
